<%--
  Created by IntelliJ IDEA.
  User: Mikey
  Date: 2017/6/10
  Time: 18:17
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>react text</title>
</head>
<body>
    <div id="app">
        <div>
            <input type="text" class="text" :value="text"/>
            <a href="javascript:void(0)" @click="initTime">推送</a>
        </div>
        <div>
            <canvas id="canvas" style="width: 200px; height: 150px;"></canvas>
        </div>
    </div>
</body>
<script type="text/javascript" src="/static/jquery/jquery-3.2.1.min.js"></script>
<script src="https://cdn.bootcss.com/vue/2.3.3/vue.min.js"></script>
<script>
    var app = new Vue({
        el : "#app",
        data : {
            time : null,
            text : 0
        },
        methods : {
            jpush : function (){
                this.text = parseInt(Math.random()*100);
                $.ajax({
                    url : "/jpush.json",
                    type : "POST",
                    data : {
                        text : this.text
                    },
                    success : function (ret) {
                        if(ret.msg == "success"){

                        }else{
                            console.log(ret.msg)
                        }
                    }
                })
            },
            initTime : function () {
                this.time = setInterval(function () {
                    this.jpush()
                }.bind(this),1000)
            }
        },
    });
</script>
</html>
